package com.sinosoft.msf.base.supplier.pojo;

import cn.hutool.core.util.StrUtil;
import com.sinosoft.msf.base.supplier.expection.BizError;

/**
 * @author : yangguodong
 * @description : Base模块的错误码
 * @program :
 * @date : 2023/12/15
 */
public enum BaseError implements BizError {
    Base_ERROR_400(100001,"请求参数不正确"),
    Base_ERROR_401(100002,"请授权后操作"),
    Base_ERROR_403(100003,"没有该操作权限"),
    Base_ERROR_405(100004,"请求方法不正确"),
    Base_ERROR_429(100005,"请求过于频繁,请稍后重试"),
    Base_ERROR_500(100006,"系统异常"),
    Base_ERROR_404(100007,"请求路径不存在"),
    BASE_ERROR_100008(100008,"会议室基础配置查询接口处理异常"),
    BASE_ERROR_100010(100010,"参会记录列表查询接口处理异常"),
    BASE_ERROR_100012(100012,"会议详情查询接口处理异常"),
    BASE_ERROR_100013(100013,"会议预约取消处理异常"),
    BASE_ERROR_100019(100019,"会议纪要提交接口处理异常"),
    BASE_ERROR_100021(100021,"会议室信息查询接口处理异常"),
    BASE_ERROR_100023(100023,"会务人员/审批人员查询接口处理异常"),
    BASE_ERROR_100024(100024,"登录信息查询接口业务层发生异常"),
    BASE_ERROR_100025(100025,"登录信息查询接口处理异常"),
    BASE_ERROR_100026(100026,"共享职场预约报表查询接口处理异常"),
    BASE_ERROR_100027(100027,"机构查询接口处理异常"),
    BASE_ERROR_100028(100028,"数据处理异常，请重新提交"),
    BASE_ERROR_100033(100033,"工会信箱 信件新建接口接口发生异常"),
    BASE_ERROR_100034(100034,"未查到此数据"),


    Base_ERROR(999999,"发生错误");

    private String code;
    private String errorMsg;
    private Object[] params;

    BaseError(int code, String errorMsg) {
        this.code = getPreFix() + code;
        this.errorMsg = errorMsg;
    }


    public String getCode1() {
        return code;
    }

    @Override
    public int getCode(){
        return 0;
    }

    public String getPreFix() {
        return "CZF"+"B";
    }

    @Override
    public String getErrorMsg() {
        if (params != null && params.length > 0) {
            return StrUtil.format(errorMsg, params);
        }
        return errorMsg;
    }

    @Override
    public BizError setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
        return this;
    }

    public BaseError setParams(Object... params) {
        this.params = params;
        return this;
    }
}
